/*
 *    Copyright (c) 2018-2025, proj All rights reserved.
 *
 * Redistribution and use in source and binary forms, with or without
 * modification, are permitted provided that the following conditions are met:
 *
 * Redistributions of source code must retain the above copyright notice,
 * this list of conditions and the following disclaimer.
 * Redistributions in binary form must reproduce the above copyright
 * notice, this list of conditions and the following disclaimer in the
 * documentation and/or other materials provided with the distribution.
 * Neither the name of the proj developer nor the names of its
 * contributors may be used to endorse or promote products derived from
 * this software without specific prior written permission.
 * Author: proj
 */

package com.ykht.proj.coupon.mapper;

import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ykht.proj.activity.vo.CardShopDto;
import com.ykht.proj.activity.vo.CnDiscountShopVoReq;
import com.ykht.proj.activity.vo.CnGroupShopVoReq;
import com.ykht.proj.coupon.dto.SearchDto;
import com.ykht.proj.coupon.entity.CnBrand;
import com.ykht.proj.coupon.entity.CnShop;
import com.ykht.proj.coupon.vo.*;
import com.ykht.proj.coupon.vo.AboutShopReq;
import com.ykht.proj.coupon.vo.AboutShopVo;
import com.ykht.proj.coupon.vo.CnCouponDetailResp;
import com.ykht.proj.coupon.vo.CnShopVo;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;

import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * 店铺表
 *
 * @author proj code generator
 * @date 2020-11-18 17:10:45
 */
@Mapper
public interface CnShopMapper extends BaseMapper<CnShop> {

	List<CnShopVo> findPage(Page page, @Param("map") HashMap map);

	AboutShopVo aboutShop(@Param("req") AboutShopReq aboutShopReq);
	IPage<AboutShopVo> aboutMaxCouponShopList(Page page,@Param("req") AboutShopReq req);


	IPage<AboutShopVo> aboutShopList(Page page, @Param("req") AboutShopReq aboutShopReq);
	List<AboutShopVo> aboutShopList( @Param("req") AboutShopReq aboutShopReq);

	List<CnShopVo> findPage(Page page, @Param("map") CnShopVo cnShopVo);

	List<CnShop> getShopByBrandList(@Param("list") List<CnBrand> brandList);

	/**
	 * C端（用户） 首页  爆款优惠
	 *
	 * @param longitude 经度
	 * @param latitude  纬度
	 * @param userId    登录人ID
	 * @return
	 */
	List<CnCouponDetailResp> getHotCouponList(@Param("longitude") String longitude,
											  @Param("latitude") String latitude, @Param("userId") Long userId);

	List<SearchDto> search(@Param("req") SearchReq searchReq);

	List<CnShopDisVo> shopAndDistant(@Param("req") CnShopDisVo cnShopDisVo);

	List<CnShopDisVo> shopAndDistant4NotTyCoupon(@Param("latitude") String latitude, @Param("longitude") String longitude, @Param("couponId") Long couponId);

	IPage<AboutShopVo> pageByCoupon(Page page, @Param("req") AboutShopByCouponReq req);

	/**
	 * 获取不是多门店的优惠券
	 *
	 * @param longitude
	 * @param latitude
	 * @param userId
	 * @return
	 */
	List<CnCouponDetailResp> getCommonCouponList(@Param("longitude") String longitude,
												 @Param("latitude") String latitude, @Param("userId") Long userId, @Param("ids") List<Long> ids);

	/**
	 * 获取多门店的优惠券
	 *
	 * @param longitude
	 * @param latitude
	 * @param userId
	 * @return
	 */
	List<CnCouponDetailResp> getMultiStoreCouponList(@Param("longitude") String longitude,
													 @Param("latitude") String latitude, @Param("userId") Long userId, @Param("ids") List<Long> ids);

	/**
	 * 获取单个门店的优惠券
	 *
	 * @param longitude
	 * @param latitude
	 * @param userId
	 * @return
	 */
	List<CnCouponDetailResp> getSingleStoreCouponList(@Param("longitude") String longitude,
													  @Param("latitude") String latitude, @Param("userId") Long userId, @Param("ids") List<Long> ids);

	/**
	 * 获取创建活动的门店
	 *
	 * @param labelId 标签ID
	 * @param name    门店名称
	 * @return
	 */
	List<CnShop> getActivityShop(@Param("labelId") Long labelId, @Param("name") String name);

	List<CnShop> listByVoMap(Map<String, Object> map);

    CnShopVo getDetailById(Long id);

	List<Long> distanceShop(@Param("req")PpgDetailReq req);

    List<Long> findByIds(@Param("split") List<Long> split,@Param("fxConfRewardVo") FxConfRewardVO fxConfRewardVo);

	String getShopByBrandId(Long brandId);

	List<CnShopSimpleVo> distanceShopByBranbdId(@Param("req")PpgDetailReq req);

	Long distanceByLonLat(@Param("templonLat") BaseLonLat templonLat,@Param("lonLat")BaseLonLat lonLat);

	/**
	 * 创建群组取门店列表（根据品牌标签, 品牌/门店名, 地址查询,协议类型)
	 * @param cnGroupShopVoReq
	 * @return
	 */
	List<CnGroupShopVoReq> getByGroup(@Param("req") CnGroupShopVoReq cnGroupShopVoReq);

	/**
	 * 获取卡能使用门店列表 （根据品牌标签, 品牌/门店名, 地址查询赛选）
	 * @param cardShopDto
	 * @return
	 */
	List<CardShopDto> getByInfoShop(@Param("req") CardShopDto cardShopDto);

	/**
	 * 根据门店ID获取全部门店信息
	 * @param shopId
	 * @return
	 */
	CnShopVo getByShopId(@Param("shopId") Long shopId);

	/**
	 * 创建优惠方案获取门店列表（根据品牌id, 门店名, 地址查询)
	 * @param page
	 * @param cnDiscountShopVoReq
	 * @return
	 */
    IPage<CnDiscountShopVoReq> getByDiscountPlan(Page page, @Param("req") CnDiscountShopVoReq cnDiscountShopVoReq);

    Long nearShopIdByBrandIdAndLanlon(@Param("brandId")Long brandId, @Param("lonLat")BaseLonLat lonLat);
    List<CnShopDisVo> nearShopIdByBrandIdsAndLanlon(@Param("brandIds") Collection brandIds, @Param("lonLat")BaseLonLat lonLat);

	List<Long> brandIdByDistant(@Param("lonLat") BaseLonLat lonLat,@Param("distance") Long distance);

    /**
	 * S-01首页（门店）分页查询
	 *
	 * @param page     分页
	 * @param homePageSearch 条件
	 * @return
	 */
	IPage<CnShopVo> getCmsShopPage(Page page, @Param("req") HomePageSearch homePageSearch);
}
